function transitionTime(t) {
    if (!t) {
        return
    }
    let time = t.slice(6, -2)
    var date = new Date(Number(time));
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');

    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
function getPreviousMonthDateTime() {
    const now = new Date();
    const currentMonth = now.getMonth();
    const previousMonthDateTime = new Date(now); // 克隆当前日期时间对象

    // 设置月份为前一个月
    previousMonthDateTime.setMonth(currentMonth - 1);

    // 格式化日期时间为字符串，方便展示（例如：YYYY-MM-DD HH:mm:ss）
    const year = previousMonthDateTime.getFullYear();
    const month = String(previousMonthDateTime.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1
    const day = String(previousMonthDateTime.getDate()).padStart(2, '0');
    const hours = String(previousMonthDateTime.getHours()).padStart(2, '0');
    const minutes = String(previousMonthDateTime.getMinutes()).padStart(2, '0');
    const seconds = String(previousMonthDateTime.getSeconds()).padStart(2, '0');

    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
function getCurrentDateTime() {
    const now = new Date();

    // 获取年份、月份、日期、小时、分钟和秒
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1
    const day = String(now.getDate()).padStart(2, '0');
    const hours = String(now.getHours()).padStart(2, '0');
    const minutes = String(now.getMinutes()).padStart(2, '0');
    const seconds = String(now.getSeconds()).padStart(2, '0');

    // 格式化为字符串，方便展示（例如：YYYY-MM-DD HH:mm:ss）
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}


export {
    transitionTime,
    getPreviousMonthDateTime,
    getCurrentDateTime
}